
/**
 * Record pre-insert trigger.
 * Validate the record to be inserted.
 * When false is returned the record will not be inserted in the database.
 * When an exception is thrown the record will also not be inserted in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/contable/asiento_prov>} record record that will be inserted
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"03B70837-2A3B-4399-9D1A-3E8D62369630"}
 */
function onAsiento_provRecordInsert(record) {
	record.aux_cuenta = utils.numberFormat(record.asiento_prov_to_cuentas.capitulo,"#") + utils.numberFormat(record.asiento_prov_to_cuentas.subcapitulo,"#")+
		utils.numberFormat(record.asiento_prov_to_cuentas.rubro,"#")	   + utils.numberFormat(record.asiento_prov_to_cuentas.cuenta,"0000")+
		utils.numberFormat(record.asiento_prov_to_cuentas.subcuenta,"0000");

	var $imp_carga = record.importe
	
	if (record.columna == "D")
	{
		record.importe_haber 	= null
		record.haber_pesos 		= null
		record.importe_debe 	= $imp_carga
		record.debe_pesos 		= record.importe
	}
	else
	{
		record.importe_haber 	= $imp_carga
		record.haber_pesos 		= record.importe
		record.importe_debe 	= null
		record.debe_pesos 		= null
	}
	return true
}
